package com.xjh.him.util;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class FileUtil {
    public static final String IMAGE_BASE_PATH = System.getProperty("user.dir") + "/static/image/";
    public static final String FILE_BASE_PATH = System.getProperty("user.dir") + "/static/file/";
    public static final String TYPE_IMAGE = "image";
    public static final String TYPE_FILE = "file";
    private static final int FILE_NAME_LENGTH = 16;



    public static String generateFileName(String suffixName) {
        int randomStrLength = 10, restLength = FILE_NAME_LENGTH - randomStrLength;
        String curUnix = String.valueOf(System.currentTimeMillis());
        return RandomUtil.randomIntString(randomStrLength) +
                curUnix.substring(curUnix.length()-restLength) + suffixName;
    }
}
